TARGET = build
CLASSPATH := $(TARGET)/:libs/ext/j3dcore.jar:libs/ext/j3dutils.jar:libs/ext/vecmath.jar:libs/ext/bluecove-gpl-2.1.0.jar:libs/ext/bluecove-2.1.0.jar:$(CLASSPATH)
LD_LIBRARY_PATH := libs/amd64/:$(LD_LIBRARY_PATH)
JFLAGS = -implicit:class -cp $(CLASSPATH) -g -d $(TARGET)/
JC = javac

FILES = \
	de/school/cbs/cube/Led.class \
	de/school/cbs/cube/LedRow.class \
	de/school/cbs/cube/LedLayer.class \
	de/school/cbs/cube/LedCube.class \
	de/school/cbs/cube/JLedServer.class

CLASSES = $(addprefix $(TARGET)/, $(FILES))

MANIFEST = MANIFEST.MF
OUTPUT   = BTServer.jar

default: run

run: jar
	java -jar $(OUTPUT)

jar: libs classes
	jar cvfm $(OUTPUT) $(MANIFEST) -C $(TARGET)/ .

libs:
	cp -r libs/* $(TARGET)/

classes: createDir $(CLASSES)

$(CLASSES): build/%.class: src/%.java
	$(JC) $(JFLAGS) $<

createDir:
	mkdir -p $(TARGET)

clean:
	$(RM) -rfv $(OUTPUT) $(TARGET)

